﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace hozorghiab
{
    public partial class editedays : Form
    {
        public sql sqlquery;
        string year, month, day, begin, end, t;
        public editedays(sql s, string year, string month, string day, string t, string begin, string end)
        {
            InitializeComponent();
            sqlquery = s;
            this.year = year;
            this.month = month;
            this.day = day;
            this.t = t;
            this.begin = begin.Trim();
            this.end = end.Trim();
        }

        private void savebutton_Click(object sender, EventArgs e)
        {
            sqlquery.open();
            string holiday;
            holiday = holidaycheckBox.Checked ? "1" : "0";
            sqlquery.ExecuteNonQuery("UPDATE days SET holiday=" + holiday + ",beginhour=" + beginhour.Value + ",beginmin=" + beginmin.Value + ",endhour=" + endhour.Value + ",endmin=" + endmin.Value + " WHERE year=" + year + " and month=" + month + " and day=" + day);
            sqlquery.close();
            Close();
        }

        private void holidaycheckBox_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void exitbutton_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void editedays_Load_1(object sender, EventArgs e)
        {
            yaertextBox1.Text = year;
            monthtextBox.Text = month;
            daytextBox.Text = day;
            beginhour.Value = int.Parse(begin.Substring(0, begin.IndexOf(":")));
            beginmin.Value = int.Parse(begin.Substring(begin.IndexOf(":") + 1, begin.Length - begin.IndexOf(":") - 1));
            endhour.Value = int.Parse(end.Substring(0, end.IndexOf(":")));
            endmin.Value = int.Parse(end.Substring(end.IndexOf(":") + 1, end.Length - end.IndexOf(":") - 1));
        }

    }
}
